package com.szzg10.webservice.chapter5;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;

import com.szzg10.webservice.chapter5.wsimport.TempConvert;
import com.szzg10.webservice.chapter5.wsimport.TempConvertImplService;

public class TempConvertSecureClient {

//	private static final String endpoint = "https://localhost:8443/szzg10/tc";
	private static final String endpoint = "http://localhost:8080/szzg10/tc";
	
	public static void main(String[] args) {
		TempConvertImplService service = new TempConvertImplService();
		TempConvert port = service.getTempConvertImplPort();
		
		Map<String, Object> context = ((BindingProvider)port).getRequestContext();
		context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
		
		Map<String, List<String>> headers = new HashMap<String, List<String>>();
		headers.put(BindingProvider.USERNAME_PROPERTY, Collections.singletonList("fred"));
		headers.put(BindingProvider.PASSWORD_PROPERTY, Collections.singletonList("rockbed"));
		context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
		
		System.out.println("f2c(-40.1) ==> " + port.f2C(-40.1f));
		System.out.println("c2f(-40.1) ==> " + port.c2F(-40.1f));
		System.out.println("f2c(+98.7) ==> " + port.f2C(98.7f));
	}
}
